<!doctype html>



  


<html class="theme-next muse use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.1" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Linux命令," />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.1" />






<meta name="description" content="&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;tcpdump是一个用于截取网络分组，并输出分组内容的工具。tcpdump凭借强大的功能和灵活的截取策略，使其成为类UNIX系统下用于网络分析和问题排查的首选工具。  &amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;tcpdump提供了源代码，公开了接口，">
<meta name="keywords" content="Linux命令">
<meta property="og:type" content="article">
<meta property="og:title" content="Linux 命令- tcpdump">
<meta property="og:url" content="https://hcldirgit.github.io/2017/09/03/2. Linux 命令/79. Linux 命令- tcpdump/index.html">
<meta property="og:site_name" content="失落的乐章">
<meta property="og:description" content="&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;tcpdump是一个用于截取网络分组，并输出分组内容的工具。tcpdump凭借强大的功能和灵活的截取策略，使其成为类UNIX系统下用于网络分析和问题排查的首选工具。  &amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;tcpdump提供了源代码，公开了接口，">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2017-09-01T08:38:58.898Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Linux 命令- tcpdump">
<meta name="twitter:description" content="&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;tcpdump是一个用于截取网络分组，并输出分组内容的工具。tcpdump凭借强大的功能和灵活的截取策略，使其成为类UNIX系统下用于网络分析和问题排查的首选工具。  &amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;tcpdump提供了源代码，公开了接口，">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Muse',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":0,"b2t":false,"scrollpercent":false},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://hcldirgit.github.io/2017/09/03/2. Linux 命令/79. Linux 命令- tcpdump/"/>





  <title>Linux 命令- tcpdump | 失落的乐章</title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  




<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
            (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
          m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
  ga('create', '85*****1', 'auto');
  ga('send', 'pageview');
</script>


  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?87980c**************99ec5e26fb5";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>











  
  
    
  

  <div class="container sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">失落的乐章</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">技术面前，永远都是学生。</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-message">
          <a href="/message" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-external-link"></i> <br />
            
            留言
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="https://hcldirgit.github.io/2017/09/03/2. Linux 命令/79. Linux 命令- tcpdump/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="失落的乐章">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/0.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="失落的乐章">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">Linux 命令- tcpdump</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-09-03T01:57:34+08:00">
                2017-09-03
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;tcpdump是一个用于截取网络分组，并输出分组内容的工具。tcpdump凭借强大的功能和灵活的截取策略，使其成为类UNIX系统下用于网络分析和问题排查的首选工具。 </p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;tcpdump提供了源代码，公开了接口，因此具备很强的可扩展性，对于网络维护和入侵者都是非常有用的工具。tcpdump存在于基本的Linux系统中，由于它需要将网络界面设置为混杂模式，普通用户不能正常执行，但具备root权限的用户可以直接执行它来获取网络上的信息。因此系统中存在网络分析工具主要不是对本机安全的威胁，而是对网络上的其他计算机的安全存在威胁。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;有时候也许有这样的需求，想看一下某个网卡上都有哪些数据包，尤其是当初判定服务器上有流量攻击。这时使用tcpdump来抓一下数据包，就可以知道有哪些IP在攻击了。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;如果系统没有tcpdump这个命令需要用yum安装一下。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">yum install -y tcpdump</div></pre></td></tr></table></figure>
<h2 id="命令格式"><a href="#命令格式" class="headerlink" title="命令格式"></a>命令格式</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">tcpdump [-nn] [-i 接口] [-w 存储档名] [-c 次数] [-Ae] [-qX] [-r 文件] [所欲捕获的数据内容]</div></pre></td></tr></table></figure>
<h2 id="命令参数"><a href="#命令参数" class="headerlink" title="命令参数"></a>命令参数</h2><ul>
<li>-A 以ASCII格式打印出所有分组，并将链路层的头最小化。 </li>
<li>-c 在收到指定的数量的分组后，tcpdump就会停止。 </li>
<li>-C 在将一个原始分组写入文件之前，检查文件当前的大小是否超过了参数file_size 中指定的大小。如果超过了指定大小，则关闭当前文件，然后在打开一个新的文件。参数 file_size 的单位是兆字节（是1,000,000字节，而不是1,048,576字节）。 </li>
<li>-d 将匹配信息包的代码以人们能够理解的汇编格式给出。 </li>
<li>-dd 将匹配信息包的代码以c语言程序段的格式给出。 </li>
<li>-ddd 将匹配信息包的代码以十进制的形式给出。 </li>
<li>-D 打印出系统中所有可以用tcpdump截包的网络接口。 </li>
<li>-e 在输出行打印出数据链路层的头部信息。 </li>
<li>-E 用spi@ipaddr algo:secret解密那些以addr作为地址，并且包含了安全参数索引值spi的IPsec ESP分组。 </li>
<li>-f 将外部的Internet地址以数字的形式打印出来。 </li>
<li>-F 从指定的文件中读取表达式，忽略命令行中给出的表达式。 </li>
<li>-i 指定监听的网络接口。 </li>
<li>-l 使标准输出变为缓冲行形式，可以把数据导出到文件。 </li>
<li>-L 列出网络接口的已知数据链路。 </li>
<li>-m 从文件module中导入SMI MIB模块定义。该参数可以被使用多次，以导入多个MIB模块。 </li>
<li>-M 如果tcp报文中存在TCP-MD5选项，则需要用secret作为共享的验证码用于验证TCP-MD5选选项摘要（详情可参考RFC 2385）。 </li>
<li>-b 在数据-链路层上选择协议，包括ip、arp、rarp、ipx都是这一层的。</li>
<li>-n 不把网络地址转换成名字。</li>
<li>-nn 不进行端口名称的转换。</li>
<li>-N 不输出主机名中的域名部分。例如，‘nic.ddn.mil‘只输出’nic‘。 </li>
<li>-t 在输出的每一行不打印时间戳。 </li>
<li>-O 不运行分组分组匹配（packet-matching）代码优化程序。 </li>
<li>-P 不将网络接口设置成混杂模式。 </li>
<li>-q 快速输出。只输出较少的协议信息。 </li>
<li>-r 从指定的文件中读取包(这些包一般通过-w选项产生)。 </li>
<li>-S 将tcp的序列号以绝对值形式输出，而不是相对值。 </li>
<li>-s 从每个分组中读取最开始的snaplen个字节，而不是默认的68个字节。 </li>
<li>-T 将监听到的包直接解释为指定的类型的报文，常见的类型有rpc远程过程调用）和snmp（简单网络管理协议；）。 </li>
<li>-t 不在每一行中输出时间戳。 </li>
<li>-tt 在每一行中输出非格式化的时间戳。 </li>
<li>-ttt 输出本行和前面一行之间的时间差。 </li>
<li>-tttt 在每一行中输出由date处理的默认格式的时间戳。 </li>
<li>-u 输出未解码的NFS句柄。 </li>
<li>-v 输出一个稍微详细的信息，例如在ip包中可以包括ttl和服务类型的信息。 </li>
<li>-vv 输出详细的报文信息。 </li>
<li>-w 直接将分组写入文件中，而不是不分析并打印出来。</li>
</ul>
<h2 id="命令功能"><a href="#命令功能" class="headerlink" title="命令功能"></a>命令功能</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;顾名思义，tcpdump可以将网络中传送的数据包的“头”完全截获下来提供分析。他支持针对网络层、协议、主机、网络或端口的过滤，并提供and、or、not等逻辑语句来帮助去掉无用的信息。</p>
<h2 id="tcpdump的表达式"><a href="#tcpdump的表达式" class="headerlink" title="tcpdump的表达式"></a>tcpdump的表达式</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;表达式是一个正则表达式，tcpdump利用它作为过滤报文的条件，如果一个报文满足表 达式的条件，则这个报文将会被捕获。如果没有给出任何条件，则网络上所有的信息包 将会被截获。 </p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;在表达式中一般如下几种类型的关键字：</p>
<h3 id="第一种是关于类型的关键字"><a href="#第一种是关于类型的关键字" class="headerlink" title="第一种是关于类型的关键字"></a>第一种是关于类型的关键字</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;主要包括host、net、prot，例如host 210.27.48.2 ，指明210.27.48.2是一台主机，net202.0.0.0指明202.0.0.0是一个网络地址，port 23 指明端口号是23.如果没有指定类型，缺省的类型是host。</p>
<h3 id="第二种是确定传输方向的关键字"><a href="#第二种是确定传输方向的关键字" class="headerlink" title="第二种是确定传输方向的关键字"></a>第二种是确定传输方向的关键字</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;主要包括src、dst、dst or src、dst and src，这些关键字指明了传输的方向。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;举例说明，src 210.27.48.2，指明ip包中源地址是210.27.48.2，dst net 202.0.0.0指明目的网络地址是202.0.0.0.如果没有指明方向关键字，则缺省是src or dst关键字。</p>
<h3 id="第三种是协议的关键字"><a href="#第三种是协议的关键字" class="headerlink" title="第三种是协议的关键字"></a>第三种是协议的关键字</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;主要包括fddi、ip、arp、rarp、tcp、udp等类型。fddi指明是在FDDI（分布式光纤数据接口网络）上的特定的网络协议，实际上它是“ether”的别名，fddi和ether具有类似的源地址和目的地址，所以可以将fddi协议包当作ether包进行处理和分析。其他的几个关键字就是指明了监听的包的协议内容。如果没有指定任何协议，则tcpdump将会监听所有协议的信息包。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;除了这三种类型的关键字之外，其他重要的关键字如下：gateway、breadcast、less、greater，还有三种逻辑运算，取非运算是‘not’ ‘!’，与运算是‘and’，‘&amp;&amp;’；或运算是‘or’，‘&amp;#124；……#124;’；这些关键字可以组合起来构成强大的组合条件来满足人们的需要。</p>
<h2 id="输出结果介绍"><a href="#输出结果介绍" class="headerlink" title="输出结果介绍"></a>输出结果介绍</h2><h3 id="数据链路层头信息"><a href="#数据链路层头信息" class="headerlink" title="数据链路层头信息"></a>数据链路层头信息</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">tcpdump --e host localhost</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;localhost 是一台linux主机。它的MAC地址是0：90：27：58：AF：1A H219是一台装有Solaris的SUN工作站。它的MAC地址是8：0：20：79：5B：46； 上一条命令的输出结果如下所示：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">21:50:12.847509 eth0 &lt; 8:0:20:79:5b:46 0:90:27:58:af:1a ip 60: h219.33357 &gt; ICE. telne t 0:0(0) ack 22535 win 8760 (DF)</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;21：50：12是显示的时间， 847509是ID号，eth0 &lt;表示从网络接口eth0接收该分组， eth0 &gt;表示从网络接口设备发送分组， 8:0:20:79:5b:46是主机H219的MAC地址， 它表明是从源地址H219发来的分组. 0:90:27:58:af:1a是主机ICE的MAC地址， 表示该分组的目的地址是ICE。 ip 是表明该分组是IP分组，60 是分组的长度， h219.33357 &gt; ICE. telnet 表明该分组是从主机H219的33357端口发往主机ICE的 TELNET(23)端口。 ack 22535 表明对序列号是222535的包进行响应。 win 8760表明发 送窗口的大小是8760。</p>
<h3 id="ARP包的tcpdump输出信息"><a href="#ARP包的tcpdump输出信息" class="headerlink" title="ARP包的tcpdump输出信息"></a>ARP包的tcpdump输出信息</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">tcpdump arp</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;输出结果</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">22:32:42.802509 eth0 &gt; arp who-has route tell ICE (0:90:27:58:af:1a)</div><div class="line">22:32:42.802902 eth0 &lt; arp reply route is-at 0:90:27:12:10:66 (0:90:27:58:af:1a)</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;22:32:42是时间戳， 802509是ID号， eth0 &gt;表明从主机发出该分组，arp表明是ARP请求包， who-has route tell ICE表明是主机ICE请求主机route的MAC地址。 0:90:27:58:af:1a是主机 ICE的MAC地址。</p>
<h3 id="TCP包的输出信息"><a href="#TCP包的输出信息" class="headerlink" title="TCP包的输出信息"></a>TCP包的输出信息</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;用tcpdump捕获的TCP包的一般输出信息是：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">src &gt; dst: flags data-seqno ack window urgent options</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;src &gt; dst:表明从源地址到目的地址， flags是TCP报文中的标志信息，S 是SYN标志， F (FIN)， P (PUSH) ， R (RST) “.” (没有标记); data-seqno是报文中的数据 的顺序号， ack是下次期望的顺序号， window是接收缓存的窗口大小， urgent表明 报文中是否有紧急指针。 Options是选项。 </p>
<h3 id="UDP包的输出信息"><a href="#UDP包的输出信息" class="headerlink" title="UDP包的输出信息"></a>UDP包的输出信息</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;用tcpdump捕获的UDP包的一般输出信息是： </p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">route.port1 &gt; ICE.port2: udp lenth</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;UDP十分简单，上面的输出行表明从主机route的port1端口发出的一个UDP报文 到主机ICE的port2端口，类型是UDP， 包的长度是lenth。 </p>
<h2 id="使用实例"><a href="#使用实例" class="headerlink" title="使用实例"></a>使用实例</h2><h3 id="实例1：默认启动"><a href="#实例1：默认启动" class="headerlink" title="实例1：默认启动"></a>实例1：默认启动</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">tcpdump</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>输出</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div></pre></td><td class="code"><pre><div class="line">[root@localhost ~]<span class="comment"># tcpdump</span></div><div class="line">tcpdump: verbose output suppressed, use -v or -vv <span class="keyword">for</span> full protocol decode</div><div class="line">listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes</div><div class="line">12:53:58.186853 IP 192.168.0.73.ssh &gt; 192.168.0.100.49602: Flags [P.], seq 2571645771:2571645967, ack 2817097466, win 141, length 196</div><div class="line">12:53:58.187498 IP 192.168.0.73.43721 &gt; www.routerlogin.com.domain: 13011+ PTR? 100.0.168.192.in-addr.arpa. (44)</div><div class="line">12:53:58.193280 IP www.routerlogin.com.domain &gt; 192.168.0.73.43721: 13011 NXDomain* 0/1/0 (93)</div><div class="line">12:53:58.193391 IP 192.168.0.73.54701 &gt; www.routerlogin.com.domain: 55618+ PTR? 73.0.168.192.in-addr.arpa. (43)</div><div class="line">12:53:58.198669 IP www.routerlogin.com.domain &gt; 192.168.0.73.54701: 55618 NXDomain* 0/1/0 (92)</div><div class="line">12:53:58.198775 IP 192.168.0.73.39373 &gt; www.routerlogin.com.domain: 10426+ PTR? 1.0.168.192.in-addr.arpa. (42)</div><div class="line">12:53:58.200468 IP www.routerlogin.com.domain &gt; 192.168.0.73.39373: 10426- 1/0/0 PTR www.routerlogin.com. (75)</div><div class="line">12:53:58.200515 IP 192.168.0.73.ssh &gt; 192.168.0.100.49602: Flags [P.], seq 196:376, ack 1, win 141, length 180</div><div class="line">12:53:58.200595 IP 192.168.0.100.49602 &gt; 192.168.0.73.ssh: Flags [.], ack 376, win 256, length 0</div><div class="line">12:53:58.208513 IP 192.168.0.73.ssh &gt; 192.168.0.100.49602: Flags [P.], seq 376:1276, ack 1, win 141, length 900</div><div class="line">12:53:58.224403 IP 192.168.0.73.ssh &gt; 192.168.0.100.49602: Flags [P.], seq 1276:1440, ack 1, win 141, length 164</div><div class="line">12:53:58.224597 IP 192.168.0.100.49602 &gt; 192.168.0.73.ssh: Flags [.], ack 1440, win 252, length 0</div><div class="line">12:53:58.239996 IP 192.168.0.73.ssh &gt; 192.168.0.100.49602: Flags [P.], seq 1440:1700, ack 1, win 141, length 260</div><div class="line">12:53:58.255361 IP 192.168.0.73.ssh &gt; 192.168.0.100.49602: Flags [P.], seq 1700:1864, ack 1, win 141, length 164</div><div class="line">12:53:58.255508 IP 192.168.0.100.49602 &gt; 192.168.0.73.ssh: Flags [.], ack 1864, win 256, length 0</div><div class="line">12:53:58.271142 IP 192.168.0.73.ssh &gt; 192.168.0.100.49602: Flags [P.], seq 1864:2124, ack 1, win 141, length 260</div><div class="line">12:53:58.286589 IP 192.168.0.73.ssh &gt; 192.168.0.100.49602: Flags [P.], seq 2124:2288, ack 1, win 141, length 164</div><div class="line">12:53:58.286754 IP 192.168.0.100.49602 &gt; 192.168.0.73.ssh: Flags [.], ack 2288, win 254, length 0</div><div class="line">12:53:58.286912 IP 192.168.0.73.ssh &gt; 192.168.0.100.49602: Flags [P.], seq 2288:2548, ack 1, win 141, length 260</div><div class="line">12:53:58.302161 IP 192.168.0.73.ssh &gt; 192.168.0.100.49602: Flags [P.], seq 2548:2712, ack 1, win 141, length 164</div><div class="line">12:53:58.302377 IP 192.168.0.100.49602 &gt; 192.168.0.73.ssh: Flags [.], ack 2712, win 253, length 0</div><div class="line">12:53:58.302462 IP 192.168.0.73.ssh &gt; 192.168.0.100.49602: Flags [P.], seq 2712:2972, ack 1, win 141, length 260</div><div class="line">12:53:58.317893 IP 192.168.0.73.ssh &gt; 192.168.0.100.49602: Flags [P.], seq 2972:3136, ack 1, win 141, length 164</div><div class="line">12:53:58.318078 IP 192.168.0.100.49602 &gt; 192.168.0.73.ssh: Flags [.], ack 3136, win 251, length 0</div><div class="line">12:53:58.318149 IP 192.168.0.73.ssh &gt; 192.168.0.100.49602: Flags [P.], seq 3136:3300, ack 1, win 141, length 164</div><div class="line">12:53:58.333352 IP 192.168.0.73.ssh &gt; 192.168.0.100.49602: Flags [P.], seq 3300:3560, ack 1, win 141, length 260</div><div class="line">12:53:58.333507 IP 192.168.0.100.49602 &gt; 192.168.0.73.ssh: Flags [.], ack 3560, win 256, length 0</div><div class="line">12:53:58.348907 IP 192.168.0.73.ssh &gt; 192.168.0.100.49602: Flags [P.], seq 3560:3820, ack 1, win 141, length 260</div><div class="line">12:53:58.366358 IP 192.168.0.73.ssh &gt; 192.168.0.100.49602: Flags [P.], seq 3820:3984, ack 1, win 141, length 164</div><div class="line">12:53:58.366514 IP 192.168.0.100.49602 &gt; 192.168.0.73.ssh: Flags [.], ack 3984, win 254, length 0</div><div class="line">12:53:58.381239 IP 192.168.0.73.ssh &gt; 192.168.0.100.49602: Flags [P.], seq 3984:4244, ack 1, win 141, length 260</div><div class="line">12:53:58.396759 IP 192.168.0.73.ssh &gt; 192.168.0.100.49602: Flags [P.], seq 4244:4408, ack 1, win 141, length 164</div><div class="line">12:53:58.396965 IP 192.168.0.100.49602 &gt; 192.168.0.73.ssh: Flags [.], ack 4408, win 253, length 0</div><div class="line">12:53:58.412465 IP 192.168.0.73.ssh &gt; 192.168.0.100.49602: Flags [P.], seq 4408:4668, ack 1, win 141, length 260</div><div class="line">12:53:58.428078 IP 192.168.0.73.ssh &gt; 192.168.0.100.49602: Flags [P.], seq 4668:4832, ack 1, win 141, length 164</div><div class="line">12:53:58.428276 IP 192.168.0.100.49602 &gt; 192.168.0.73.ssh: Flags [.], ack 4832, win 251, length 0</div><div class="line">12:53:58.443786 IP 192.168.0.73.ssh &gt; 192.168.0.100.49602: Flags [P.], seq 4832:5092, ack 1, win 141, length 260</div><div class="line">12:53:58.459211 IP 192.168.0.73.ssh &gt; 192.168.0.100.49602: Flags [P.], seq 5092:5256, ack 1, win 141, length 164</div><div class="line">12:53:58.459444 IP 192.168.0.100.49602 &gt; 192.168.0.73.ssh: Flags [.], ack 5256, win 256, length 0</div><div class="line">12:53:58.474768 IP 192.168.0.73.ssh &gt; 192.168.0.100.49602: Flags [P.], seq 5256:5516, ack 1, win 141, length 260</div><div class="line">12:53:58.490445 IP 192.168.0.73.ssh &gt; 192.168.0.100.49602: Flags [P.], seq 5516:5680, ack 1, win 141, length 164</div><div class="line">12:53:58.490611 IP 192.168.0.100.49602 &gt; 192.168.0.73.ssh: Flags [.], ack 5680, win 254, length 0</div><div class="line">12:53:58.490693 IP 192.168.0.73.ssh &gt; 192.168.0.100.49602: Flags [P.], seq 5680:5940, ack 1, win 141, length 260</div><div class="line">12:53:58.490904 IP 192.168.0.73.ssh &gt; 192.168.0.100.49602: Flags [P.], seq 5940:6104, ack 1, win 141, length 164</div><div class="line">12:53:58.491013 IP 192.168.0.100.49602 &gt; 192.168.0.73.ssh: Flags [.], ack 6104, win 253, length 0</div><div class="line">12:53:58.506024 IP 192.168.0.73.ssh &gt; 192.168.0.100.49602: Flags [P.], seq 6104:6364, ack 1, win 141, length 260</div><div class="line">12:53:58.516922 IP 192.168.0.100.49602 &gt; 192.168.0.73.ssh: Flags [P.], seq 1:53, ack 6364, win 252, length 52</div><div class="line">12:53:58.517035 IP 192.168.0.73.ssh &gt; 192.168.0.100.49602: Flags [P.], seq 6364:6528, ack 53, win 141, length 164</div><div class="line">^C</div><div class="line">48 packets captured</div><div class="line">51 packets received by filter</div><div class="line">0 packets dropped by kernel</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>说明</strong></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;普通情况下，直接启动tcpdump将监视第一个网络接口上所有流过的数据包</p>
<h3 id="实例2：监视指定网络接口的数据包"><a href="#实例2：监视指定网络接口的数据包" class="headerlink" title="实例2：监视指定网络接口的数据包"></a>实例2：监视指定网络接口的数据包</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">tcpdump -i eth1</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>说明</strong><br>如果不指定网卡，默认tcpdump只会监视第一个网络接口，一般是eth0。</p>
<h3 id="实例3：以IP与port-number抓下eth0这个网卡上-使得数据包"><a href="#实例3：以IP与port-number抓下eth0这个网卡上-使得数据包" class="headerlink" title="实例3：以IP与port number抓下eth0这个网卡上 使得数据包"></a>实例3：以IP与port number抓下eth0这个网卡上 使得数据包</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">tcpdump -i eth0 -nn</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>输出</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div></pre></td><td class="code"><pre><div class="line">[root@localhost ~]<span class="comment"># tcpdump -nn -i eth0</span></div><div class="line">tcpdump: verbose output suppressed, use -v or -vv <span class="keyword">for</span> full protocol decode</div><div class="line">listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes</div><div class="line">13:00:35.277585 IP 192.168.0.73.22 &gt; 192.168.0.100.49602: Flags [P.], seq 2573734647:2573734843, ack 2817100566, win 141, length 196</div><div class="line">13:00:35.277769 IP 192.168.0.100.49602 &gt; 192.168.0.73.22: Flags [.], ack 196, win 252, length 0</div><div class="line">13:00:35.292177 IP 192.168.0.73.22 &gt; 192.168.0.100.49602: Flags [P.], seq 196:472, ack 1, win 141, length 276</div><div class="line">13:00:35.307810 IP 192.168.0.73.22 &gt; 192.168.0.100.49602: Flags [P.], seq 472:636, ack 1, win 141, length 164</div><div class="line">13:00:35.308018 IP 192.168.0.100.49602 &gt; 192.168.0.73.22: Flags [.], ack 636, win 251, length 0</div><div class="line">13:00:35.338945 IP 192.168.0.73.22 &gt; 192.168.0.100.49602: Flags [P.], seq 636:896, ack 1, win 141, length 260</div><div class="line">13:00:35.340898 IP 192.168.0.73.22 &gt; 192.168.0.100.49602: Flags [P.], seq 896:1060, ack 1, win 141, length 164</div><div class="line">13:00:35.341088 IP 192.168.0.100.49602 &gt; 192.168.0.73.22: Flags [.], ack 1060, win 256, length 0</div><div class="line">13:00:35.356706 IP 192.168.0.73.22 &gt; 192.168.0.100.49602: Flags [P.], seq 1060:1320, ack 1, win 141, length 260</div><div class="line">13:00:35.356935 IP 192.168.0.73.22 &gt; 192.168.0.100.49602: Flags [P.], seq 1320:1484, ack 1, win 141, length 164</div><div class="line">13:00:35.357059 IP 192.168.0.100.49602 &gt; 192.168.0.73.22: Flags [.], ack 1484, win 254, length 0</div><div class="line">13:00:35.372128 IP 192.168.0.73.22 &gt; 192.168.0.100.49602: Flags [P.], seq 1484:1744, ack 1, win 141, length 260</div><div class="line">13:00:35.382482 IP 192.168.0.100.49602 &gt; 192.168.0.73.22: Flags [P.], seq 1:53, ack 1744, win 253, length 52</div><div class="line">13:00:35.382649 IP 192.168.0.73.22 &gt; 192.168.0.100.49602: Flags [P.], seq 1744:2020, ack 53, win 141, length 276</div><div class="line">^C</div><div class="line">14 packets captured</div><div class="line">14 packets received by filter</div><div class="line">0 packets dropped by kernel</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>说明</strong><br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;第三列和第四列显示的信息为哪一个IP+port 在连接哪一个IP+port，后面的信息是该数据包的相关信息。这里需要关注的只是第三列以及第四列。<code>-i</code>选项后面跟设备名称，如果想抓其他网卡的包，后面则要跟其他网卡名。至于<code>-nn</code>选项是作用是让第三列和第四列西安市城IP+端口号的形式，如果不加<code>-nn</code>则显示的是主机名+服务名称。</p>
<h3 id="实例4：截获所有210-27-48-1的主机收到的和发出的所有的数据"><a href="#实例4：截获所有210-27-48-1的主机收到的和发出的所有的数据" class="headerlink" title="实例4：截获所有210.27.48.1的主机收到的和发出的所有的数据"></a>实例4：截获所有210.27.48.1的主机收到的和发出的所有的数据</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">tcpdump host 210.27.48.1</div></pre></td></tr></table></figure>
<h3 id="实例5：截获主机210-24-48-1和主机210-24-48-2或210-27-48-3的通信"><a href="#实例5：截获主机210-24-48-1和主机210-24-48-2或210-27-48-3的通信" class="headerlink" title="实例5：截获主机210.24.48.1和主机210.24.48.2或210.27.48.3的通信"></a>实例5：截获主机210.24.48.1和主机210.24.48.2或210.27.48.3的通信</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">tcpdump host 210.2748.1 and 210.27.48.2 or 210.27.48.3</div></pre></td></tr></table></figure>
<h3 id="实例6：获取主机210-27-48-1除了和主机210-27-48-2之外所有主机通信的ip包"><a href="#实例6：获取主机210-27-48-1除了和主机210-27-48-2之外所有主机通信的ip包" class="headerlink" title="实例6：获取主机210.27.48.1除了和主机210.27.48.2之外所有主机通信的ip包"></a>实例6：获取主机210.27.48.1除了和主机210.27.48.2之外所有主机通信的ip包</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">tcpdump ip host 210.27.48.1 and ! 210.27.48.2</div></pre></td></tr></table></figure>
<h3 id="实例7：获取主机192-168-228-246接收或发出的ssh包，并且不转换主机名"><a href="#实例7：获取主机192-168-228-246接收或发出的ssh包，并且不转换主机名" class="headerlink" title="实例7：获取主机192.168.228.246接收或发出的ssh包，并且不转换主机名"></a>实例7：获取主机192.168.228.246接收或发出的ssh包，并且不转换主机名</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">tcpdump -nn -n src host 192.168.228.246 and port 22 and tcp</div></pre></td></tr></table></figure>
<h3 id="实例8：获取主机192-168-228-246接收或发出的ssh包，并把mac地址也一同显示"><a href="#实例8：获取主机192-168-228-246接收或发出的ssh包，并把mac地址也一同显示" class="headerlink" title="实例8：获取主机192.168.228.246接收或发出的ssh包，并把mac地址也一同显示"></a>实例8：获取主机192.168.228.246接收或发出的ssh包，并把mac地址也一同显示</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">tcpdump  -e src host 192.168.228.246 and port 22 and tcp -n -nn</div></pre></td></tr></table></figure>
<h3 id="实例9：过滤的是源主机为192-168-0-1与目的网路哦为192-168-0-0的报头"><a href="#实例9：过滤的是源主机为192-168-0-1与目的网路哦为192-168-0-0的报头" class="headerlink" title="实例9：过滤的是源主机为192.168.0.1与目的网路哦为192.168.0.0的报头"></a>实例9：过滤的是源主机为192.168.0.1与目的网路哦为192.168.0.0的报头</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">tcpdump src host 192.168.0.1 and dst net 192.168.0.0/24</div></pre></td></tr></table></figure>
<h3 id="实例10：过滤源主机物理地址为XXX的报头"><a href="#实例10：过滤源主机物理地址为XXX的报头" class="headerlink" title="实例10：过滤源主机物理地址为XXX的报头"></a>实例10：过滤源主机物理地址为XXX的报头</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">tcpdump ether src 00:50:04:BA:98 and dst……</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;ether src后面没有host或者net，物理地址当然不可能有网络。</p>
<h3 id="实例11：过滤源主机192-168-0-1和目的端口不是telnet的报头，并导入到test-txt文件中"><a href="#实例11：过滤源主机192-168-0-1和目的端口不是telnet的报头，并导入到test-txt文件中" class="headerlink" title="实例11：过滤源主机192.168.0.1和目的端口不是telnet的报头，并导入到test.txt文件中"></a>实例11：过滤源主机192.168.0.1和目的端口不是telnet的报头，并导入到test.txt文件中</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">tcpdump src host 192.168.0.1 and dst port not telnet -l &gt; test.txt</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;ip、icmp、arp、rarp 和 tcp、udp、icmp这些选项等都要放到第一个参数的位置，用来过滤数据报的类型。</p>
<h3 id="实例12：捕获192-168-1-100主机eth1网卡上80端口接收和发出的数据100条，并保存文件1-cap"><a href="#实例12：捕获192-168-1-100主机eth1网卡上80端口接收和发出的数据100条，并保存文件1-cap" class="headerlink" title="实例12：捕获192.168.1.100主机eth1网卡上80端口接收和发出的数据100条，并保存文件1.cap"></a>实例12：捕获192.168.1.100主机eth1网卡上80端口接收和发出的数据100条，并保存文件1.cap</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">tcpdump -nn -i eth1 host 192.168.1.100 and port 80 -c 100 -w 1.cap</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>说明</strong></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;用host指定ip，port指定端口，-c指定包数量，-w写入指定文件里。而不加 -w直接在屏幕上显示的不是数据包，而是数据流向。这个1.cap可以下载到windows上，谈后用wireshark查看。</p>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/Linux命令/" rel="tag"># Linux命令</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2017/09/03/1. Linux 基础/3. Linux 快捷键/" rel="next" title="Linux 快捷键">
                <i class="fa fa-chevron-left"></i> Linux 快捷键
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/09/03/2. Linux 命令/83. Linux 命令- nohup/" rel="prev" title="Linux 命令- nohup">
                Linux 命令- nohup <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/0.png"
               alt="失落的乐章" />
          <p class="site-author-name" itemprop="name">失落的乐章</p>
           
              <p class="site-description motion-element" itemprop="description">失落的乐章的Blog</p>
          
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/">
                <span class="site-state-item-count">627</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">38</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/hcldirgit" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
          
        </div>

        
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#命令格式"><span class="nav-number">1.</span> <span class="nav-text">命令格式</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#命令参数"><span class="nav-number">2.</span> <span class="nav-text">命令参数</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#命令功能"><span class="nav-number">3.</span> <span class="nav-text">命令功能</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#tcpdump的表达式"><span class="nav-number">4.</span> <span class="nav-text">tcpdump的表达式</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#第一种是关于类型的关键字"><span class="nav-number">4.1.</span> <span class="nav-text">第一种是关于类型的关键字</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#第二种是确定传输方向的关键字"><span class="nav-number">4.2.</span> <span class="nav-text">第二种是确定传输方向的关键字</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#第三种是协议的关键字"><span class="nav-number">4.3.</span> <span class="nav-text">第三种是协议的关键字</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#输出结果介绍"><span class="nav-number">5.</span> <span class="nav-text">输出结果介绍</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#数据链路层头信息"><span class="nav-number">5.1.</span> <span class="nav-text">数据链路层头信息</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#ARP包的tcpdump输出信息"><span class="nav-number">5.2.</span> <span class="nav-text">ARP包的tcpdump输出信息</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#TCP包的输出信息"><span class="nav-number">5.3.</span> <span class="nav-text">TCP包的输出信息</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#UDP包的输出信息"><span class="nav-number">5.4.</span> <span class="nav-text">UDP包的输出信息</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#使用实例"><span class="nav-number">6.</span> <span class="nav-text">使用实例</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#实例1：默认启动"><span class="nav-number">6.1.</span> <span class="nav-text">实例1：默认启动</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#实例2：监视指定网络接口的数据包"><span class="nav-number">6.2.</span> <span class="nav-text">实例2：监视指定网络接口的数据包</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#实例3：以IP与port-number抓下eth0这个网卡上-使得数据包"><span class="nav-number">6.3.</span> <span class="nav-text">实例3：以IP与port number抓下eth0这个网卡上 使得数据包</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#实例4：截获所有210-27-48-1的主机收到的和发出的所有的数据"><span class="nav-number">6.4.</span> <span class="nav-text">实例4：截获所有210.27.48.1的主机收到的和发出的所有的数据</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#实例5：截获主机210-24-48-1和主机210-24-48-2或210-27-48-3的通信"><span class="nav-number">6.5.</span> <span class="nav-text">实例5：截获主机210.24.48.1和主机210.24.48.2或210.27.48.3的通信</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#实例6：获取主机210-27-48-1除了和主机210-27-48-2之外所有主机通信的ip包"><span class="nav-number">6.6.</span> <span class="nav-text">实例6：获取主机210.27.48.1除了和主机210.27.48.2之外所有主机通信的ip包</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#实例7：获取主机192-168-228-246接收或发出的ssh包，并且不转换主机名"><span class="nav-number">6.7.</span> <span class="nav-text">实例7：获取主机192.168.228.246接收或发出的ssh包，并且不转换主机名</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#实例8：获取主机192-168-228-246接收或发出的ssh包，并把mac地址也一同显示"><span class="nav-number">6.8.</span> <span class="nav-text">实例8：获取主机192.168.228.246接收或发出的ssh包，并把mac地址也一同显示</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#实例9：过滤的是源主机为192-168-0-1与目的网路哦为192-168-0-0的报头"><span class="nav-number">6.9.</span> <span class="nav-text">实例9：过滤的是源主机为192.168.0.1与目的网路哦为192.168.0.0的报头</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#实例10：过滤源主机物理地址为XXX的报头"><span class="nav-number">6.10.</span> <span class="nav-text">实例10：过滤源主机物理地址为XXX的报头</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#实例11：过滤源主机192-168-0-1和目的端口不是telnet的报头，并导入到test-txt文件中"><span class="nav-number">6.11.</span> <span class="nav-text">实例11：过滤源主机192.168.0.1和目的端口不是telnet的报头，并导入到test.txt文件中</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#实例12：捕获192-168-1-100主机eth1网卡上80端口接收和发出的数据100条，并保存文件1-cap"><span class="nav-number">6.12.</span> <span class="nav-text">实例12：捕获192.168.1.100主机eth1网卡上80端口接收和发出的数据100条，并保存文件1.cap</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">失落的乐章</span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Muse
  </a>
</div>


        

        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.1"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.1"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.1"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.1"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.1"></script>



  


  




	





  





  





  






  





  

  

  

  

  

  

</body>
</html>
